var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    info:null,
    news:[],
    goods_list:[]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var t = this
    wx.showLoading({
      title: '加载中',
    })
    setTimeout(function () {
      t.getlist();
    }, 200)
  },
  getlist: function (options){
    //if (!options.shop_id) {
    var options = { "shop_id": app.globalData.shop_id }
   // }
    app.ihttpGet('https://www.58zltc.com/api.php/Shop/item/shop_id/' + options.shop_id, res => {
      this.setData({
        info: res.data
      })
      wx.setNavigationBarTitle({
        title: res.data.name,
      })
    })
    app.ihttpGet('https://www.58zltc.com/api.php/Jiaoyu/news/shop_id/' + options.shop_id, res => {
      this.setData({
        news: res.data
      })
    })
    app.ihttpGet('https://www.58zltc.com/api.php/Goods/index/shop_id/' + options.shop_id, res => {
      this.setData({
        goods_list: res.data
      })
    })
    app.ihttpGet('https://www.58zltc.com/api.php/Coupon/index/shop_id/' + options.shop_id, res => {
      this.setData({
        coupon_list: res.data
      })
    })
    //setTimeout(function () {
      wx.hideLoading();
    //}, 3000)
  },
  getCoupon: function (e) {
    let that = this;
    const id = e.currentTarget.dataset.id;
    var post_data = {};
    post_data.coupon_id = id;
    post_data.openid = app.globalData.openid;
    app.ihttpPost("https://www.58zltc.com/api.php/Coupon/getCoupon", post_data, function (res) {
      app.iModel(res.data.err_msg);
    })
  },
  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
    const shop = this.data.info;
    return {
      title: shop.name,
      path: '/pages/jiaoyu/detail?shop_id=' + shop.shop_id
    }
  }
})